package cn.rkylin.oms.warehouse.stockGoods.dao;

import java.util.List;
import java.util.Map;

import cn.rkylin.oms.warehouse.stockGoods.vo.StockGoodsExportVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.github.pagehelper.PageInfo;

import cn.rkylin.core.IDataBaseFactory;
import cn.rkylin.oms.warehouse.stockGoods.domain.StockGoods;
import cn.rkylin.oms.warehouse.stockGoods.vo.StockGoodsVO;

/**
 * 库存汇总DAO实现类
 *
 * @author zhangheng
 * @date 2018/01/23
 */
@Repository(value = "stockGoodsDAO")
public class StockGoodsDAOImpl implements IStockGoodsDAO{
    @Autowired
    protected IDataBaseFactory dao;

    private static final String STATEMENT_PAGE_SELECT_BY_CONDITION = "pageSelectStockGoods";
    private static final String STATEMENT_SELECT_GOODS_LOCA = "selectStockGoodsLoca";
    private static final String STATEMENT_SELECT_GOODS_EXT = "selectStockGoodsExt";
    private String STATEMENT_SELECT_DETAIL_BY_PRIMARYKEY = "selectDetailByPrimaryKey";

    /**
     * selectPagedByCondition：根据查询条件获取库存信息汇总列表
     */
    @Override
    public PageInfo<StockGoodsVO> selectPagedByCondition(int page, int length, StockGoodsVO queryParamVO) throws Exception {
        return dao.findPage(page, length, STATEMENT_PAGE_SELECT_BY_CONDITION, queryParamVO);
    }

    /**
     * getStockGoodsLocaStorInfo:查询商品本地库各个仓库存储情况
     */
    @Override
    public List<StockGoodsVO> getStockGoodsLocaStorInfo(StockGoodsVO queryParamVO) throws Exception {
        return dao.findAllList(STATEMENT_SELECT_GOODS_LOCA, queryParamVO);
    }

    /**
     * getStockGoodsExtStorInfo:查询商品第三方库各个仓库存储情况
     */
    @Override
    public List<StockGoodsVO> getStockGoodsExtStorInfo(StockGoodsVO queryParamVO) throws Exception {
        return dao.findAllList(STATEMENT_SELECT_GOODS_EXT, queryParamVO);
    }


    @Override
    public StockGoodsVO selectDetailByPrimaryKey(String goodsId) throws Exception {
        StockGoodsVO stockGoodsVO = new StockGoodsVO();
        stockGoodsVO.setGoodsId(goodsId);
        return dao.findOne(STATEMENT_SELECT_DETAIL_BY_PRIMARYKEY, stockGoodsVO);
    }

    public List<StockGoodsExportVO> getExportList(Map reqMap, String statement) throws Exception {
        return dao.findList(statement,reqMap);
    }

}